<?php

namespace app\api\controller\google;

use app\api\service\google\GoogleService;
use hunma\basic\ApiResponse;
use hunma\basic\BaseController;

class GoogleController extends BaseController
{
    protected $service;

    /**
     * 构造函数，初始化服务对象
     */
    public function __construct()
    {
        $this->service = new GoogleService();
    }

    public function latlng()
    {
        $rules = [
            ['address', 'require', '地址不能为空'],
        ];

        $this->parseValidationRules($rules);
        return ApiResponse::success($this->service->latlng(self::getAllParams()));
    }

    public function translate()
    {
        $rules = [
            ['content', 'require', '翻译内容不能为空'],
            ['target', 'require', '目标语言不能为空']
        ];

        $this->parseValidationRules($rules);
        return ApiResponse::success($this->service->translate(self::getAllParams()));
    }
}